package dparish.client.view;

import dparish.client.proxy.CommonEntityProxy;

/**
 * Most of the app is displaying an Entity (Student, Teacher, Class, etc). These are the presenter methods common to those entities.
 * Notice the get and set Entity.  This is because the view doesn't hold the data, the presenter does. The view just asks for the data or if the view changes the data
 * it calls setEntity.
 * @author dparish
 *
 * @param <Entity>
 */
public interface EntityView<Entity extends CommonEntityProxy> extends CommonView {
	
	  public interface Presenter<Entity> {
		  /**
		   * A save has been clicked or requested (say when finishing updating or adding a student).
		   * @param entity
		   */
		    void onSaveEvent(Entity entity);
		    
		    /**
		     * Canceling an edit.
		     */
		    void onCancelEvent();
		    void setEntity (Entity entity);
		    Entity getEntity();
		  }
	  
	  /**
	   * The view needs to know about the presenter (so it can call getEntity and setEntity for example).
	   * @param p The presenter.
	   */
	  void setPresenter (Presenter<Entity> p);
	  
	  /**
	   * The presenter does the server side communication. We need a standardized way to communicate back to the view that the save has completed.
	   * This is a simple implementation that passes in a message on error.  I suspect a more robust solution would be needed for a more complete application.
	   * @param message An error message if there is an error, null if no errors.
	   */
	  void saveCallback (String message);
}
